package org.restorator.entity;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

/**
 *
 * @author Snisar Bogdan.
 */
public abstract class Order {

    private int orderId;
    private long openDate;
    private long closeDate;
    private List<Item> items;



    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    public long getOpenDate() {
        return openDate;
    }

    public void setOpenDate(long openDate) {
        this.openDate = openDate;
    }

    public long getCloseDate() {
        return closeDate;
    }

    public void setCloseDate(long closeDate) {
        this.closeDate = closeDate;
    }

    public List<Item> getItems() {
        return items;
    }

    public void setItems(List<Item> items) {
        this.items = items;
    }

    @Override
    public String toString() {
        StringBuilder s = new StringBuilder();
        s.append("[ Order id: ").append(orderId).append(", open time ").append(openDate).append(", items: ");
        s.append(items);
        s.append(", order owner: ");
        return s.append(" ]").toString();
    }


    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result
                        + closeDate);
		result = prime * result + ((items == null) ? 0 : items.hashCode());
		result = (int) (prime * result
                        + openDate);
		result = prime * result + orderId;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;

		Order other = (Order) obj;
		if (closeDate != other.closeDate) {
				return false;
		}
		if (items == null) {
			if (other.items != null)
				return false;
		} else if (!items.equals(other.items))
			return false;
		if (openDate != other.openDate) {
            return false;
		}
        return orderId == other.orderId;
    }

	public abstract double getPrice();

}
